package com.example.cwj11_27;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;

public class ScaleAnimActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scale_anim);
        ImageView imageView = findViewById(R.id.img);
      // Animation animation = new ScaleAnimation(0.1f,2f,0.1f,2f);
      // Animation animation = AnimationUtils.loadAnimation(this,R.anim.scaleanim);
        //pivotx如果是整数值，表示中心点是从左上角往右移动指定的像素值。
       // Animation animation = new ScaleAnimation(0.1f,1f,0.1f,1f,200,200);


        //第五个参数是 int pivotXType有两种取值：1是自身，2是父容器，第七个参数是int pivotYType
       // Animation animation = new ScaleAnimation(0.1f,1f,0.1f,1f,Animation.RELATIVE_TO_PARENT,0.5f,
             // Animation.RELATIVE_TO_PARENT,0.5f);
       // ScaleAnimation animation = new ScaleAnimation(0,1,0,2,Animation.RELATIVE_TO_SELF,
               // 1f,Animation.RELATIVE_TO_SELF,1f);
        TranslateAnimation animation = new TranslateAnimation(-100,200,-110,200);


        //重复次数，首次不算
        //animation.setRepeatCount(1);
       animation.setDuration(6000);
       animation.setFillAfter(true);
       //在ImageViews上启动一个缩放动画
       imageView.startAnimation(animation);

    }
}
